<template>
  <div class="box p-5">
    <div class="row">
      <div class="col-lg-6">
        <div class="bar">
          <ul @click="handler(item.id)" :class="['item', item.isActive ? 'is-active' : '']" v-for="item in list"
            :key="item.id">
            <li>
              <span class="item-icon" :class="item.icon"></span>
              <span>
                <RouterLink class="RL" :to="item.url">{{ item.label }}</RouterLink>
              </span>
            </li>
          </ul>
        </div>
      </div>
      <div class="col-lg-6">
        <RouterView />
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import { nanoid } from 'nanoid';

const list = ref([
  {
    id: nanoid(6),
    label: 'Navigation One',
    icon: 'far fa-compass',
    isActive: false,
    url: '/nav1'
  },
  {
    id: nanoid(6),
    label: 'Navigation Two',
    icon: 'fas fa-braille',
    isActive: false,
    url: '/nav2'
  },
  {
    id: nanoid(6),
    label: 'Navigation Three',
    icon: 'fas fa-file-alt',
    isActive: false,
    url: '/nav3'
  },
  {
    id: nanoid(6),
    label: 'Navigation Four',
    icon: 'far fa-sun',
    isActive: false,
    url: '/nav4'
  },
]);

const handler = id => {
  list.value.forEach(item => {
    item.isActive = item.id == id;
  });
}

</script>

<style lang="scss" scoped>
.box {
  width: 100%;
  height: 500vh;
  // text-align: center;
}

.is-active {
  color: blue;
}

.bar {
  // position: fixed;
  // bottom: 0px;

  // display: flex;
  // justify-content: space-evenly;
  // align-items: center;

  // width: 100%;
  // box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);

}

li {
  list-style: none;
}

.item {
  // display: flex;
  // flex-direction: column;
  // justify-content: center;
  // align-items: center;
  // width: 10px;
  padding: 15px;

  &-icon {
    font-size: 25px;
  }
}
.item-icon{
  width: 30px;
  margin-left: 20px;
}
.RL {
  margin-left: 20px;
  text-decoration: none;
  color: #000;
}
</style>